// pages/set_up/set_up.js
var that
var app = getApp()
Page({
  data: {
  catch_size:null,

  num:0,//邀请剩余次数
  code:'',
  },
  onLoad: function (options) {
    that=this;
    this.getcatch();
    that.get_invite_time();
  },
  onReady: function () {
   
  },
  onShow: function () {
  
  },
 get_invite_time:function(){
   app.req("get_invite_time.html", {"openid": app.data.openid}, function (res) {
     if (res.status == "success") { 
       if (res.mess > 0) { that.setData({ num: res.mess })}
       that.setData({ code: res.code.invite_code })
     } else if (res.status == "error") {
       app.toast(res.mess)
     } else {
       app.modal("错误提示", "网络错误，是否重试？", function (re) {
         if (re) {
           that.get_invite_time()
         }
       })
     }
   })
 },
  getcatch:function(){
    var that=this;
    try {//同步获取缓存内容
      var res = wx.getStorageInfoSync()
      // console.log(res);
      that.setData({ catch_size: res.currentSize});
    } catch (e) {
      // Do something when catch error
    }
  },
 
  clear_catch:function(){  //清除缓存
    try {
      wx.clearStorageSync()
    } catch (e) {}
    this.getcatch();
    wx.showToast({
      title: '清除缓存成功',
      duration: 2000
    })
  },
  exit_up:function(){   //退出登陆
    wx.showModal({
      content: '确定退出当前账户？',
      success: function (res) {
        if (res.confirm) {
          // console.log('用户点击确定')
           
        }
      }
    })
  }

})